﻿using MediatR;
using T_settlement.API.Application.Command.PaymentCommand;
using T_settlement.Infrastructure.Interfacec;

namespace T_settlement.API.Application.CommandHandlers.PaymentCommandHandlers
{
    public class StateSPaymentCommandHandlers:IRequestHandler<StateSPaymentCommand,int>
    {
        private readonly IPaymentRepository paymentRepository;

        public StateSPaymentCommandHandlers(IPaymentRepository paymentRepository)
        {
            this.paymentRepository = paymentRepository;
        }

        public async Task<int> Handle(StateSPaymentCommand request, CancellationToken cancellationToken)
        {
            var Info = await paymentRepository.GetModelAsync(request.PaymentId);
            Info.AuditState = request.AuditState;
            Info.Approver = "小明";
            var res = await paymentRepository.UpdateAsync(Info);
            return res;
        }
    }
}
